<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.onlineMIS.ORM.entity.chainS.inventoryFlow.ChainInventoryFlowOrder,com.onlineMIS.ORM.entity.chainS.user.ChainRoleType" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<script type="text/javascript" src="<%=request.getContextPath()%>/conf_files/js/inventory/inventory.js?v=1.11"></script>
<script>
var dataGrid ;
$(document).ready(function(){
	parent.$.messager.progress('close'); 
	loadResult();
	var orderId = $("#orderId").val();
	dataGrid = $('#dataGrid').datagrid({
			url : 'headqInventoryFlowJSONAction!selectOrderProductDetails',
			queryParams: {
				'formBean.flowOrder.id':orderId
			},
            fitColumns: true,
            fit: true,
            singleSelect: true,
            rowStyler: function(index,row){
    			var style = "";
    			if (row.quantity > 10)
    				style += 'color:red;';
    			return style;
    		},
    		showFooter:true,
    		rownumbers:true,
    		editable: false,
            columns: [[
            	
            	{field: 'year', title: '年份', width: 20},
            	{field: 'quarter', title: '季度', width: 20},
            	{field: 'brand', title: '品牌', width: 50},
            	{field: 'categoryLevel', title: '产品线', width: 30},
                {field: 'category', title: '货品类别', width: 50},
            	{field: 'productCode', title: '货号', width: 30},                          
                {field: 'colorName', title: '颜色', width: 30},
                {field: 'barcode', title: '条码', width: 60},
                {field: 'unit', title: '单位', width: 30},                                
                {field: 'quantity', title: '数量', width: 20},         
                {field: 'comment', title: '摘要', width: 70},
                {field: 'action', title: '图片', width: 30,
        			formatter : function(value, row, index) {
        				if(row.id !=0){
	        				var str = '';     				
	        				str += $.formatString('<a href="#" onclick="viewImgP(\'{0}\');"><img border="0" src="{1}" /></a>', row.barcode,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/img3.png');        			       				
	        				return str;
        				}
        			}},
        		{field: 'scanNums', title: '扫描次数', width: 20},
            ]]});
});

function downloadOrderTwo(){
    document.headqInventoryFlowForm.action="headqInventoryFlowJSPAction!downloadFlowOrder";
    document.headqInventoryFlowForm.submit();
}


//红冲单据  
function headqCancelOrder(){
	$.messager.confirm('确认', "确认红冲单据", function(r){
		if (r){
			   $.messager.progress({
					text : '数据处理中，请稍后....'
				});		   
			   	var url = "<%=request.getContextPath()%>/action/headqInventoryFlowJSONAction!cancelOrder";
				var params=$("#headqInventoryFlowForm").serialize();  
				$.post(url,params, cancelOrderBackProcess,"json");
		}
	});
}

/**
 * 红冲单据->回调方法
 */
function cancelOrderBackProcess(data){
	$.messager.progress('close');
    var response = data;
	var returnCode = response.returnCode;
	if (returnCode != SUCCESS)
		$.messager.alert('错误', response.message, 'error');
	else {
		$.messager.alert({
			title: '成功',
			closable: false,
			msg: '单据红冲成功！',
			fn: function(){
				parent.closeTab();
			}
		});
    }		
}

</script>
</head>
<body>
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 130px;">
	<%@ include file="../common/JRComponent.jsp"%>
    <s:form action="/action/headqInventoryFlowJSPAction!editOrder" method="POST" name="headqInventoryFlowForm" id="headqInventoryFlowForm" theme="simple">
	<s:hidden name="formBean.flowOrder.id"/>   
	<input type= "hidden" id="orderId" value='<s:property value="formBean.flowOrder.id"/>'></input>
    <table width="98%" align="center"  class="OuterTable">
	    <tr><td>	        
			 <table width="100%" border="0" >
			     <tr>			 
			       <td height="50" colspan="7">
				   	 <table width="100%" border="0">
				   	 <tr class="PBAOuterTableTitale">
				         <td height="32" colspan="5">
				              	<s:property value="formBean.flowOrder.typeHQS"/>:<s:property value="formBean.flowOrder.id"/>
				         </td>
			           </tr>				      
				       <tr class="InnerTableContent">
			        
				         <td width="12%"><strong>创建人:&nbsp;   </strong><s:property value="uiBean.flowOrder.creator.name"/></td>
				         <td width="15%"><strong>日期:&nbsp;   </strong><s:property value="uiBean.flowOrder.orderDate"/></td>
				         <td width="15%"><strong>状态: &nbsp;  </strong>
				         	  <s:if test="uiBean.flowOrder.status == 3">
				              		 <font style="color:red"><s:property value="uiBean.flowOrder.statusS"/></font>
				              </s:if><s:else>
				                     <s:property value="uiBean.flowOrder.statusS"/>
				              </s:else>
				         </td>
				      	 <td width="35%" height="32">
							<strong>查找条码：</strong>
							<s:textfield cssClass="easyui-searchbox" id="barcode" data-options="prompt:'请输入需要查询的条码',searcher:searchBarcode" size="30" />		
						</td>					         
				         <td>
				        	 <s:if test=" formBean.canDownload">
						            <a href="#" class="easyui-linkbutton c8" style="width:100px; height: 25px;"  onclick="downloadOrderTwo();">下载单据</a>
						      </s:if>
				         	<s:if test=" formBean.canCancel">
						          <a href="#" class="easyui-linkbutton c3" style="width:100px; height: 25px;"  onclick="headqCancelOrder();">红冲单据</a>
								</s:if>									      				         
				         </td>
				       </tr>
				       <tr>
				       		<td  height="32"><strong>调出:&nbsp;  </strong><s:property value="uiBean.flowOrder.fromStore.name"/></td>
				         	<td ><strong>调入:&nbsp;  </strong><s:property value="uiBean.flowOrder.toStore.name"/></td>
				       		<td  ><strong>备注：&nbsp;  </strong><s:property value="uiBean.flowOrder.comment"/></td>
				       		<td colspan="2"></td>
				       </tr>
				     </table>
				     </td>				
			  </table>
	   </td></tr>
	 </table>
	 </s:form>
	 </div>
	 <div data-options="region:'center',border:false">
			<table id="dataGrid"></table>
		</div>
</div>	
</body>
</html>